import java.util.HashSet;

/*
 *
 * HashSet存储自定义类型的元素
 *
 *   set集合存储元素唯一：
 *       存储的元素（String,Integer,...,Students,Persons ）
 *
 *   要求：
 *   同名和同龄的视为同一个人
 *
 * */
public class HashSetSavePerson {
    public static void main(String[] args) {
        Person one = new Person("张三", 20);
        Person two = new Person("张三", 22);
        Person three = new Person("张三", 20);

        HashSet<Person> set = new HashSet<>();
        set.add(one);
        set.add(two);
        set.add(three);
        System.out.println(set);
        boolean equals = one.equals(three);
        System.out.println(equals);
    }
}
